package com.lagou.module.dao;

import com.lagou.module.entity.User;
import com.lagou.module.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class UserDaoImpl implements UserDao {


    @Override
    public User userLogin(User user) {

        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        String sql = "select * from t_user where username = ? and password = ? ";

        try {
            User tu = queryRunner.query(sql, new BeanHandler<User>(User.class), user.getUserName(), user.getPassword());
            return tu;
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;



    }
}
